<?php
class XSession {
	public function __set( $name, $value ){
		$_SESSION[$name] = $value;
	}
	
	public function __get( $name ){
		return $_SESSION[$name];
	}
	
	public function init(){
		session_start();
	}
	
	/**
	 * Delete the value which named $name in session.
	 *
	 * @param string $name
	 */
	public function delete( $name ){
		$_SESSION[$name] = null;
		unset($_SESSION[$name]);
	}
	
	public function clear(){
		$_SESSION = array();
		session_destroy();
	}
	
	/**
	 * Check whether there is a value named $name.
	 *
	 * @param string $name
	 * @return bool
	 */
	public function has( $name ){
		return isset($_SESSION[$name]);
	}
}